<?php
namespace Amis\form;
class ListSelect extends FormItem
{
    public string $type = 'list-select';

    /**
     * 动态选项组
     * @param $options
     * @return $this
     */
    public function options($options)
    {
        $this->options = $options;
        return $this;
    }

    /**
     * 动态选项组
     * @param $source string或 API
     * @return $this
     */
    public function source($source)
    {
        $this->source = $source;
        return $this;
    }

    /**
     * @param bool $multiple
     * @return $this
     */
    public function multiple(bool $multiple = false)
    {
        $this->multiple = $multiple;
        return $this;
    }

    /**
     * 选项标签字段
     * @param string $labelField
     * @return $this
     */
    public function labelField(string $labelField = 'label')
    {
        $this->labelField = $labelField;
        return $this;
    }

    /**
     * 选项值字段
     * @param string $valueField
     * @return $this
     */
    public function valueField(string $valueField = 'label')
    {
        $this->valueField = $valueField;
        return $this;
    }

    /**
     *    拼接值
     * @param bool $joinValues
     * @return $this
     */
    public function joinValues(bool $joinValues = true)
    {
        $this->joinValues = $joinValues;
        return $this;
    }

    /**
     * @param bool $extractValue
     * @return $this
     */
    public function extractValue(bool $extractValue = false)
    {
        $this->extractValue = $extractValue;
        return $this;
    }

    /**
     * 自动填充
     * @param bool $autoFill
     * @return $this
     */
    public function autoFill(bool $autoFill = false)
    {
        $this->autoFill = $autoFill;
        return $this;
    }

    /**
     * 支持配置 list div 的 css 类名。比如: flex justify-between
     * @param string $listClassName
     * @return $this
     */
    public function listClassName(string $listClassName)
    {
        $this->listClassName = $listClassName;
        return $this;
    }
}